package com.munhrasoft.elearning.business.entities;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;

@Entity
@NamedQueries(value = {
    @NamedQuery(name = "findAllCourses", query = "SELECT c FROM Courses c"),
    @NamedQuery(name = "findCoursesByTitle", query = "SELECT c FROM Courses c WHERE lower(c.title) "
            + "LIKE :title") })
@SequenceGenerator(name = "coursesSeq", initialValue = 1, allocationSize = 1)
public class Courses {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "coursesSeq")
    private Long          id;
    private String        title;
    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private List<CourseClass> classes;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public List<CourseClass> getClasses() {
        return classes;
    }

    public void setClasses(List<CourseClass> classes) {
        this.classes = classes;
    }

}
